import Mock from "mockjs"


Mock.mock('/getAllList', 'get', {"list|1-3": [
    "Hello",
    "Mock.js"
  ]})
Mock.mock('/login', 'post', {username:'levi',success: true})
Mock.mock('/getBooks', 'get', {
  "books|2": [
    {
      id: "@increment()",
      title: "@title()",
      author: '@cname()',
      description: "@paragraph(1)"
    }
  ]
})

Mock.mock('/addBooks', 'post', (req) => {
  // 输出请求参数
  console.log('mock',req)
  // 返回数据
  return {
    ...req
  }
})
Mock.mock('/delBooks', 'get', (req) => {
  // 输出请求参数
  console.log('mock',req)
  // 返回数据
  return {
    'success': true
  }
})

Mock.mock('/getUsers', 'get', {
  "users|2": [
    {
      id: "@increment()",
      name: "@cname()",
      email: '@email()',
    }
  ]
})
const mockPosts =  Mock.mock('/post/', 'get', {
  "posts|2": [
    {
      id: "@increment()",
      title: "@title()",
    }
  ]
})

Mock.setup({
  // timeout: '300', // 延时300ms
  timeout: '1000-1200'
})

export default mockPosts;
